/*
 * Cursor.h
 *
 *  Created on: 4.2.2013
 *      Author: Travis
 */

#pragma once

#ifdef _WIN32 
#include <windows.h> 
#include "SDL.h"
#include "SDL_thread.h"
#else
#include "SDL/SDL.h"
#include "SDL/SDL_thread.h"
#endif

#include "../dataTypes/Cube.h"
#include "../Terrain.h"

#include "../objects/Entity.h"
#include "../objects/static/building/Building.h"
#include "../objects/static/building/BLumberjack.h"
#include "../objects/static/building/BHunter.h"
#include "../objects/static/building/BBank.h"

#include "World.h"
#include <glm/glm.hpp>

#include <vector>
#include "../console/globalConsole.h"
#include "../gameLogic/Resource.h"
#include "../gameLogic/UnitBar.h"
#include "../scene/Timer.h"

#include "../gadgets/Form.h"
#include "../gadgets/Button.h"

#include "../engine/engineSettings.h"

#define	MODE_PLAY	0
#define	MODE_EDIT	1

#define UPDATE_ENT_CUR	0
#define UPDATE_TER_CUR	1

namespace Map
{
class Map;
}

namespace RTSCursor
{

class Cursor
{
public:
	Cursor(Map::Map *_map);
	virtual ~Cursor();

	void updateOGLPos(int x, int y, int type);

	// called from thread in RTS!!!!
	void control(SDL_Event *event, float t);

	void draw();

	void selectAll();

	int getMode() const;
	void setMode(int mode);
	const glm::vec3& getOgLcursor() const;
	void setOgLcursor(const glm::vec3& ogLcursor);
	const std::vector<Entity*>& getUnitMark() const;
	void setUnitMark(const std::vector<Entity*>& unitMark);

private:
	void freeAllMarked();
	void goToAllMarked();

	int Mode; // cursor mode
	//	ID of marked units
	std::vector<Entity*> UnitMark;
	bool LeftPressed, RightPressed;

	Map::Map *map;

	glm::vec3 OGLcursor, OGLcursorTer; // position of mouse in 3D ogl projection

	// cube of edit area only in edit mode
	DataTypes::Cube *editArea;

	bool ctrl, build;

	Entity *virtualEntity;

	// gadgets
	Gadgets::Form *sideBar, *storeHouse, *woodCutter, *hunterHouse, *bankHouse;
	//--------------------
};
}

